home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-02-05 | 10.9 KB | 304 lines | [TEXT/MPS ] |
- //---------------------------------------------------------------------
- // Copyright © 1991 Apple Computer, Japan Inc. All rights reserved.
- //
- // '91 Dec.11 Programed by Taro Tanaka
- //
- // Developer Technical Supprt, Service and Support
- //
- //---------------------------------------------------------------------
-
- #include <UMacApp.h>
- #include <UPrinting.h>
- #include <UDialog.h>
- #include <UGridView.h>
- #include <ToolUtils.h>
- #include <Resources.h>
-
- #include <Aliases.h>
- #include <AppleEvents.h>
- #include <AEObjects.h>
- #include <AEPackObject.h>
- #include <Processes.h>
- #include <StandardFile.h>
- #include <Packages.h>
- #include <Sound.h>
-
- class TDraw; // forward declarations
- class TDrawView;
- class TPaletteView;
- class TShapeGridView;
- class TDrawingRect;
- class TDrawingOval;
- class TDrawingLine;
-
- typedef pascal void (*DoToADrawProc)(TDraw *aDraw, void *link);
-
- // ==========================================================================================
- class TDrawApplication: public TApplication {
- public:
- virtual pascal void IDrawApplication();
- virtual pascal TDocument* DoMakeDocument(CmdNumber itsCmdNumber);
- virtual pascal TCommand* DoMenuCommand(CmdNumber aCmdNumber);
- virtual pascal void DoSetupMenus();
- virtual pascal TCommand* HandleAlienEvent(EventInfo *theEventInfo);
- virtual pascal void HandleFinderRequest();
- };
-
- // ==========================================================================================
- class TDrawDocument: public TDocument {
- private:
- TPaletteView *fPaletteView;
- TList *fDrawList;
- short fColorCmdNumber;
- short fLineCmdNumber;
- public:
- TDrawView *fDrawView;
- virtual pascal void IDrawDocument();
- virtual pascal void AddDrawFirst(TDraw *aDraw);
- virtual pascal void AddDrawLast(TDraw *aDraw);
- virtual pascal CmdNumber GetColorCmd();
- virtual pascal void SetColorCmd(CmdNumber aCmdNumber);
- virtual pascal CmdNumber GetLineCmd();
- virtual pascal void SetLineCmd(CmdNumber aCmdNumber);
- virtual pascal void DeleteDraw(TDraw *aDraw);
- virtual pascal void DoMakeViews(Boolean forPrinting);
- virtual pascal void DoSetupMenus();
- virtual pascal TCommand * DoMenuCommand(CmdNumber aCmdNumber);
- virtual pascal TDraw *FirstDraw();
- virtual pascal void ForEachDrawDo(DoToADrawProc DoToADraw, void *DoToDraw_StaticLink);
- virtual pascal void Free(); //override
- virtual pascal void FreeData(); //overrride
- virtual pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
- virtual pascal void DoWrite(short aRefNum, Boolean makingCopy);
- virtual pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
- #if qInspector
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- #endif
- };
-
-
- // ==========================================================================================
- class TDrawView: public TView {
- private:
- TDrawDocument *fDrawDocument;
- OSType fShapeType;
- public:
- virtual pascal void IRes(TDocument *itsDocument,
- TView *itsSuperView, Ptr *itsParams);
- virtual pascal TCommand *DoMouseCommand(Point *theMouse,
- EventInfo *info, Point *hysteresis);
- virtual pascal Boolean DoSetCursor(Point localPoint, RgnHandle cursorRgn);
- virtual pascal void Draw(Rect *area);
- virtual pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint, Boolean turnItOn, Boolean mouseDidMove);
- };
-
-
- // ==========================================================================================
- class TPaletteView: public TView {
- private:
- TDrawDocument *fDrawDocument;
-
- public:
- virtual pascal void IRes(TDocument *itsDocument,
- TView *itsSuperView, Ptr *itsParams);
- virtual pascal void ChangeSelection(CmdNumber newColorNumber);
- virtual pascal TCommand *DoMouseCommand(Point *theMouse,
- EventInfo *info, Point * hysteresis);
- virtual pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
- virtual pascal void Draw(Rect *area);
- #if qInspector
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- #endif
- };
-
- // ==========================================================================================
- class TLineView: public TView {
- private:
- TDrawDocument *fDrawDocument;
- public:
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- virtual pascal void ChangeSelection(CmdNumber newColorNumber);
- virtual pascal TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point * hysteresis);
- virtual pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
- virtual pascal void Draw(Rect *area);
- };
-
- // ==========================================================================================
- class TDraw: public TObject {
- public:
- OSType fShapeType;
- Rect fFrame;
- RGBColor fColor;
- Pattern fPattern;
- short fLineSize;
- virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
- virtual pascal void DrawDraw();
- virtual pascal long ReturnBytes();
- virtual pascal void ReadDraw(short aRefNum);
- virtual pascal void WriteDraw(short aRefNum);
- virtual pascal Rect ReturnFrame();
- #if qInspector
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- #endif
- };
-
- // ==========================================================================================
- class TDrawingRect: public TDraw {
- virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
- virtual pascal void DrawDraw();
- };
-
- // ==========================================================================================
- class TDrawingOval: public TDraw {
- virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
- virtual pascal void DrawDraw();
- };
-
- // ==========================================================================================
- class TDrawingLine: public TDraw {
- private:
- Point fStartPoint;
- Point fEndPoint;
- public:
- virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
- virtual pascal void DrawDraw();
- virtual pascal long ReturnBytes();
- virtual pascal void ReadDraw(short aRefNum);
- virtual pascal void WriteDraw(short aRefNum);
- virtual pascal void IStartEnd(Point startPoint, Point endPoint);
- };
-
- // ==========================================================================================
- class TDrawingRRect: public TDraw {
- private:
- Point fOval;
- public:
- virtual pascal void IDraw(const Rect *size, RGBColor *itsColor,ConstPatternParam *itsPattern, short itsLineSize);
- virtual pascal void DrawDraw();
- virtual pascal long ReturnBytes();
- virtual pascal void ReadDraw(short aRefNum);
- virtual pascal void WriteDraw(short aRefNum);
- virtual pascal void ISetOval(Point ovalSize);
- };
-
- // ==========================================================================================
- class TDrawingPICT: public TDraw {
- private:
- PicHandle fPicHandle;
- public:
- virtual pascal void IDraw(const Rect *size, RGBColor *itsColor,ConstPatternParam *itsPattern, short itsLineSize);
- virtual pascal void DrawDraw();
- virtual pascal long ReturnBytes();
- virtual pascal void ReadDraw(short aRefNum);
- virtual pascal void WriteDraw(short aRefNum);
- virtual pascal void ISetPICT(PicHandle itsPICTHandle);
- };
-
- // ==========================================================================================
- class TSketcher: public TCommand {
- private:
- TDraw *fDraw;
- TDrawView *fDrawView;
- TDrawDocument *fDrawDocument;
- OSType fShapeType;
-
- public:
- virtual pascal void ISketcher(TDrawView *itsView, TDrawDocument*itsDocument, OSType fShapeType);
- virtual pascal TCommand *TrackMouse(TrackPhase aTrackPhase,
- VPoint *anchorPoint,
- VPoint *previousPoint,
- VPoint *nextPoint,
- Boolean mouseDidMove);
- virtual pascal void DoIt();
- virtual pascal void RedoIt();
- virtual pascal void UndoIt();
- virtual pascal void Free();
- #if qInspector
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- #endif
- };
-
- // ==========================================================================================
- class TDeleteCmd: public TCommand {
- private:
- TDraw *fDeletedDraw;
- TDrawView *fDrawView;
- TDrawDocument *fDrawDocument;
-
- public:
- virtual pascal void IDeleteCmd(TDrawView *itsView,
- TDrawDocument *itsDocument);
- virtual pascal void DoIt();
- virtual pascal void RedoIt();
- virtual pascal void UndoIt();
- virtual pascal void Free();
- #if qInspector
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- #endif
- };
-
- // ==========================================================================================
- class TShapeGridView: public TGridView {
- public:
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- virtual pascal void DrawCell(GridCell aGridCell, Rect *aQDRect);
- virtual pascal OSType GetShapeType();
- };
-
- // ==========================================================================================
- class TPatternView: public TGridView {
- private:
- virtual pascal void DrawCell(GridCell aGridCell, Rect *aQDRect);
- public:
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- virtual pascal void GetPattern(Pattern itsPattern);
- };
-
- // ==========================================================================================
- class TSetSelfCmd: public TNoChangesCommand {
- virtual pascal void DoIt();
- };
-
- // ==========================================================================================
- class TSetTargetAddress: public TNoChangesCommand {
- virtual pascal void DoIt();
- };
-
- // ==========================================================================================
- class TLaunchApplication: public TNoChangesCommand {
- virtual pascal void DoIt();
- };
-
- // ==========================================================================================
- class TAEOldDocCommand: public TOldDocCommand {
- public:
- virtual pascal void IAEOldDocCommand(CmdNumber itsCmdNumber);
- virtual pascal void DoIt();
- };
-
- // ==========================================================================================
- class TAENewDocCommand: public TNewDocCommand {
- public:
- virtual pascal void IAENewDocCommand(CmdNumber itsCmdNumber);
- virtual pascal void DoIt();
- };
-
- // ==========================================================================================
- class TAECloseWindowCommand: public TCloseWindowCommand {
- public:
- virtual pascal void IAECloseWindowCommand(CmdNumber itsCmdNumber);
- virtual pascal void DoIt();
- };
-
- // ==========================================================================================
- class TAEAboutAppCommand: public TAboutAppCommand {
- public:
- virtual pascal void DoIt();
- };
-
-